import { createRouter, createWebHistory } from 'vue-router'
import config from '@/config'; // Import the config file
// Remove MainLayout import, it's handled by App.vue
// import MainLayout from '@/components/layout/MainLayout.vue'
import HomeView from '../views/HomeView.vue'
// Ensure other necessary view imports are present


const router = createRouter({
    history: createWebHistory(import.meta.env.BASE_URL),
    routes: [
        // Define routes directly, App.vue provides the layout
        {
            path: '/',
            name: 'Home',
            component: HomeView,
            meta: { title: 'Home' }
        },
        {
            path: '/editor',
            name: 'Editor',
            component: () => import('../views/EditorView.vue'),
            meta: { title: 'Editor' }
        },
        {
            path: '/jdf-form-visualization',
            name: 'Visualizer',
            component: () => import('../views/JDFFormVisualizationView.vue'),
            meta: { title: 'Visualizer' }
        },
        {
            path: '/settings',
            name: 'Settings',
            component: () => import('../views/SettingsView.vue'),
            meta: { title: 'Settings' }
        },
        {
            path: '/files',
            name: 'FileManager',
            component: () => import('../views/FileManagerView.vue'),
            meta: { title: 'File Manager' }
        },

        // Remove the nested structure under MainLayout
    ]
})

// --- Add Navigation Guards for Logging --- COMMENT OUT GUARDS
/*
router.beforeEach((to, from) => {
  console.log(`[Router beforeEach] Navigating FROM: ${from.fullPath} (name: ${String(from.name)}) TO: ${to.fullPath} (name: ${String(to.name)})`);
  // You can return false to cancel navigation, or return a path to redirect
  // return true; // Explicitly allow navigation (default behavior)
});

router.afterEach((to, from) => {
  console.log(`[Router afterEach] Successfully navigated FROM: ${from.fullPath} (name: ${String(from.name)}) TO: ${to.fullPath} (name: ${String(to.name)})`);
});
*/
// ---------------------------------------

export default router